import { getArticleParams } from '@/store/reducer/articleList';
import request from '@/utils/request';

// 获取文章列表
export const getArticleListAPI = (params: getArticleParams) =>
  request({
    url: '/v1_0/articles',
    params,
  });

// 对文章不感兴趣
export const articleDislikeAPI = (target: string) =>
  request({
    url: '/v1_0/article/dislikes',
    method: 'post',
    data: { target },
  });

// 举报文章
export const articleReportAPI = ({
  target,
  type,
  remark,
}: {
  target: string;
  type: string;
  remark: string;
}) =>
  request({
    url: '/v1_0/article/reports',
    method: 'POST',
    data: {
      target,
      type,
      remark,
    },
  });

// 获取文文章详情
export const getArticleDetailAPI = (id: string) =>
  request({
    url: `/v1_0/articles/${id}`,
  });

// 对文章点赞
export const articleLikingAPI = (target: string) =>
  request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: { target },
  });

// 取消文章点赞
export const cancelArticleLikingAPI = (target: string) =>
  request({
    url: `/v1_0/article/likings/${target}`,
    method: 'DELETE',
  });

// 收藏文章
export const articleCollectAPI = (target: string) =>
  request({
    url: '/v1_0/article/collections',
    method: 'POST',
    data: { target },
  });

// 取消收藏文章
export const cancelArticleCollectAPI = (target: string) =>
  request({
    url: `/v1_0/article/collections/${target}`,
    method: 'DELETE',
  });
